﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VideoLib.Utils;

namespace VideoLib.Config
{
    public class AppConfig
    {
        public ObservableCollection<string> VideoPath { get; set; }

        public string PlayerPath { get; set; }

        public string Theme { get; set; } = "Light";

        public bool ShowImage { get; set; }
        public AppConfig()
        {
            VideoPath = new ObservableCollection<string>();
            PlayerPath = string.Empty;
        }

        static AppConfig()
        {
            if (!File.Exists("setting.json"))
            {
                JsonHelper.SaveJsonToFilee(new AppConfig(), "setting.json");
                return;
            }

            instance = JsonHelper.ReadJsonFromFile<AppConfig>("setting.json") ?? new AppConfig();
        }

        private static AppConfig instance;

        public static AppConfig Instance
        {
            get
            {
                instance ??= new AppConfig();
                return instance;
            }
            set { instance = value; }
        }

        public static void Save()
        {
            JsonHelper.SaveJsonToFilee(instance, "setting.json");
        }
    }
}
